/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package klijent.gui.util;

import domen.Trening;
import java.util.LinkedList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Ivan Ivic
 */
public class ModelTabeleTreninzi extends AbstractTableModel {
    LinkedList<Trening> listaTreninga;
    String[] naziviKolona = {"Sifra Treninga", "Naziv Treninga", "Cena", "Broj Termina", "Broj dana trajanja kartice", "Vreme maksimalnog dolaska"};

    public ModelTabeleTreninzi() {
        listaTreninga = new LinkedList<Trening>();
    }

    public ModelTabeleTreninzi(LinkedList<Trening> listaTreninga) {
        this.listaTreninga = listaTreninga;
    } 

    public int getRowCount() {
        return listaTreninga.size();
    }

    public int getColumnCount() {
        return 6;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Trening t = listaTreninga.get(rowIndex);
        switch(columnIndex)
        {
            case 0:
                return t.getSifraTreninga();
            case 1:
                return t.getNazivTreninga();
            case 2:
                return t.getCena();
            case 3:
                return t.getBrojTermina();
            case 4:
                return t.getBrojDanaTrajanja();
            case 5:
                return t.getVremeMaxDolaska();
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        return naziviKolona[column];
    }
    
}
